//
//  HomeHeadView.swift
//  FridgeSolo
//
//  Created by LiuXing on 2017/6/10.
//  Copyright © 2017年 kumi.com. All rights reserved.
//

import UIKit

class HomeHeadView: UIView {
    
    override init(frame: CGRect) {
        super.init(frame: frame)
//        backgroundColor = UIColor.red
        addSubview(label1)
        addSubview(label2)
        addSubview(label3)
        addSubview(label4)
        addSubview(view1)
        addSubview(view2)
        addSubview(view3)
        
//        backgroundColor = UIColor.red
        label1.snp.makeConstraints { (make) in
            make.left.equalTo(self.snp.left).offset(15)
            make.bottom.equalTo(self.snp.bottom).offset(-10)
        }
        
        label4.snp.makeConstraints { (make) in
            make.right.equalTo(self.snp.right).offset(-15)
            make.bottom.equalTo(self.snp.bottom).offset(-10)
        }
        
        view1.snp.makeConstraints { (make) in
            make.height.equalTo(25)
            make.width.equalTo(view2.snp.width)
            make.width.equalTo(view3.snp.width)
            
            make.height.equalTo(view2.snp.height)
            make.height.equalTo(view3.snp.height)
            
            make.left.equalTo(label1.snp.right)
            make.bottom.equalTo(self.snp.bottom)
            make.right.equalTo(label2.snp.left)
        }
        
        label2.snp.makeConstraints { (make) in
            make.bottom.equalTo(self.snp.bottom).offset(-10)
            make.right.equalTo(view2.snp.left)
        }
        
        view2.snp.makeConstraints { (make) in
            make.bottom.equalTo(self.snp.bottom)
            make.right.equalTo(label3.snp.left)
        }
        
        label3.snp.makeConstraints { (make) in
            make.bottom.equalTo(self.snp.bottom).offset(-10)
            make.right.equalTo(view3.snp.left)
        }
        
        view3.snp.makeConstraints { (make) in
            make.bottom.equalTo(self.snp.bottom)
            make.right.equalTo(label4.snp.left)
        }
        
        addSubview(label5)
        
        label5.snp.makeConstraints { (make) in
            make.left.equalTo(self.snp.left).offset(10)
            make.top.equalTo(self).offset(10)
        }
        
        addSubview(label6)
        addSubview(label7)
        addSubview(label8)
        addSubview(label9)
        addSubview(label10)
        addSubview(label11)
        addSubview(label12)
        
        label6.snp.makeConstraints { (make) in
            make.centerY.equalTo(self.snp.centerY)
            make.centerX.equalTo(label1.snp.centerX)
        }
        
        label7.snp.makeConstraints { (make) in
            make.centerY.equalTo(self.snp.centerY)
            make.centerX.equalTo(view1.snp.centerX)
        }
        
        label8.snp.makeConstraints { (make) in
            make.centerY.equalTo(self.snp.centerY)
            make.centerX.equalTo(label2.snp.centerX)
        }
        
        label9.snp.makeConstraints { (make) in
            make.centerY.equalTo(self.snp.centerY)
            make.centerX.equalTo(view2.snp.centerX)
        }
        
        label10.snp.makeConstraints { (make) in
            make.centerY.equalTo(self.snp.centerY)
            make.centerX.equalTo(label3.snp.centerX)
        }
        
        label11.snp.makeConstraints { (make) in
            make.centerY.equalTo(self.snp.centerY)
            make.centerX.equalTo(view3.snp.centerX)
        }
        
        label12.snp.makeConstraints { (make) in
            make.centerY.equalTo(self.snp.centerY)
            make.centerX.equalTo(label4.snp.centerX)
        }
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    // lazy
    private lazy var label1: UILabel = {
        let label = self.creatLabel(text: "Goal")
        return label
    }()
    
    private lazy var label2: UILabel = {
        let label = self.creatLabel(text: "Food")
        return label
    }()
    
    private lazy var label3: UILabel = {
        let label = self.creatLabel(text: "Exercise")
        return label
    }()
    
    private lazy var label4: UILabel = {
        let label = self.creatLabel(text: "Remaining")
        return label
    }()
    
    private lazy var label5: UILabel = {
        let label = self.creatLabel(text: "Calories Remaining")
        label.font = UIFont.systemFont(ofSize: 15)
        return label
    }()
    
    private lazy var label6: UILabel = {
        let label = self.creatLabel(text: "1,200")
        label.font = UIFont.systemFont(ofSize: 15)
        return label
    }()
    
    private lazy var label7: UILabel = {
        let label = self.creatLabel(text: "-")
        label.font = UIFont.systemFont(ofSize: 15)
        return label
    }()
    
    private lazy var label8: UILabel = {
        let label = self.creatLabel(text: "100")
        label.font = UIFont.systemFont(ofSize: 15)
        return label
    }()
    
    private lazy var label9: UILabel = {
        let label = self.creatLabel(text: "+")
        label.font = UIFont.systemFont(ofSize: 15)
        return label
    }()
    
    private lazy var label10: UILabel = {
        let label = self.creatLabel(text: "200")
        label.font = UIFont.systemFont(ofSize: 15)
        return label
    }()
    
    private lazy var label11: UILabel = {
        let label = self.creatLabel(text: "=")
        label.font = UIFont.systemFont(ofSize: 15)
        return label
    }()
    
    private lazy var label12: UILabel = {
        let label = self.creatLabel(text: "1,300")
        label.font = UIFont.systemFont(ofSize: 15)
        return label
    }()
    
    private lazy var view1: UIView = UIView()
    private lazy var view2: UIView = UIView()
    private lazy var view3: UIView = UIView()
    
    // func
    private func creatLabel(text: String) -> UILabel {
        let label = UILabel()
        label.textColor = UIColor.darkGray
        label.font = UIFont.systemFont(ofSize: 12)
        label.text = text
        return label
    }
    
}
